#ifndef GSMSNIFFERMANAGER_H
#define GSMSNIFFERMANAGER_H
#include "gsmApi.h"
#ifdef ignore
#undef ignore
#endif
#include <sstream>
#include <iostream>
#include <fstream>
#include <vector>
#include <stdint.h>
#include <arpa/inet.h>
#include <string>
#include <map>
#include <algorithm>

class gsmSnfManager
{
    typedef struct cellItemInfoTag
    {
        U16	wARFCN;
        U16	wBSIC;
        S8	cRSSI;
        U8	bReserved;
        U8	cC1;
        U8	bC2;
        U16 count;
        bool operator >(const cellItemInfoTag& rhs) const  
        {    
            if (count == rhs.count)
            {
                return cRSSI < rhs.cRSSI;
            }
            else
            {
                return count >rhs.count;
            }

        }  
    }cellItemInfo;

    typedef struct neighboringCellTag
    {
        U32		  bGlobalCellId;
        U8		  bPLMNId[5];
        S8		  cRSSI;
        U16		  wLAC;
        U16		  wBSIC;
        U16		  wARFCN;
        U8		  cC1;
        U8		  bNbCellNum;				  
        U8		  bReserved;
        U8		  bC2;
        cellItem   stNbCell[32];
        bool operator >(const neighboringCellTag& rhs) const
        {   
            return cRSSI > rhs.cRSSI;
        }
    }neighboringCell;

public:
    static gsmSnfManager* instance();
    void initGsmSnfManager();
    void handleNbCellInfo(bool isMobile, neighboringCellInfo cell);

    void handleSnifferResult();
    
    void packSnifferResult(std::stringstream &result, bool isMobileBand900, bool isUnicomBand900);
    void packSnfHandleResult(std::stringstream &result, bool isMobileBand900, bool isUnicomBand900);


private:
    gsmSnfManager();
    gsmSnfManager(const gsmSnfManager&);
    gsmSnfManager& operator=(const gsmSnfManager&);

    std::vector<neighboringCell> MobileCellInfo_;
    std::vector<neighboringCell> UnicomCellInfo_;
        
    std::vector<cellItemInfo> MobileCellItem_;
    std::vector<cellItemInfo> UnicomCellItem_;
   



};

#define gsmSnfManagerPtr (gsmSnfManager::instance())




















#endif
